Week 2 Analysis
library(mosaic)
library(tidyverse)
library(pander)
library(DT)
library(plotly)
library(readr)
options(readr.show_col_types = FALSE)
# If you get an error stating:
# Error in library(DT): there is no package called 'DT'
# You will need to run: install.packages("DT")
# in your Console, then try "Knit HTML" again.
Stephanie1 is a student that will be starting school at BYU-Idaho next semester. Suppose she sent you the following email.
“Hi. My name is Stephanie. I would like to learn about what housing options I have for living at BYU-Idaho next semester. It will be my first semester there, so I would like to find something that is close to campus and around $300 a month in rent. I’m not too picky on roommates, but I would like somewhere that has a lot of people around so I can get to know as many people as possible. Thanks in advance!”
Dear Stephanie,
Those are both respectable and understandable needs. In line with your requests, I’ve filtered the data set to only apartments that have a rent between $900 and $1400, or between $225 and $350 per month, and apartments for women. You can see the data set below:
Rent <- read_csv("../Data/Rent.csv")
F_Rent <- Rent[Rent$Gender == 'F', ]
F_Aff_Rent <- F_Rent[F_Rent$MaxFloorPlanCost > 900 & F_Rent$MaxFloorPlanCost < 1500, ]
# Code to get you started, be sure to use a subset of Rent instead of Rent in this code though.
datatable(F_Aff_Rent, options=list(lengthMenu = c(3,10,30)), extensions="Responsive")
Below I have made two charts to help draw conclusions from the data:
p <- plot_ly(data = F_Aff_Rent,
x = F_Aff_Rent$MaxFloorPlanCost,
y = F_Aff_Rent$Residents,
type = 'scatter',
mode = 'markers',
text = ~Name,
color = ~Residents
)
p <- p %>% layout(
title = "Interactive Scatter Plot with Price and Residents",
xaxis = list(title = "Max Floor Plan Cost"),
yaxis = list(title = "Residents")
)
p
Here you can see the price, and max number of residents. At the high end on both factors, Centre Square has a whopping 450 residents, but also is on the high end of the rent scale we chose. Bayside Manor is affordable, but only has 8 residents. Royal Crest seems like the clear winner, with 342 residents, but at only $995, or about $248 per month. If you want to be around more people for a premium, you can go with Univeristy View, but Royal Crest seems like the best pick here.
p <- plot_ly(
data = F_Aff_Rent,
x = ~Longitude,
y = ~Latitude,
size = ~Residents,
type = 'scatter',
mode = 'markers',
text = ~Name,
color = ~Residents
)
p <- p %>% layout(
title = "Interactive Scatter Plot with Size Based on Residents",
xaxis = list(title = "X Coordinate - Longitude"),
yaxis = list(title = "Y Coordinate - Latitude")
)
p
## Warning: `line.width` does not currently support multiple values.
Here is another perspective on your request to be around a lot of residents- this chart has the location of each apartment complex as it stands on the map, but has the size of each dot based on how many residents can live there. You can see which apartment complexes are closest to the others. The Grove on the far right, and Abby lane, on the far left for example, don’t seem close to any other complexes.
Based on your requests, I would recommend you choose Royal Crest. It is affordable, has a lot of people, is near campus and a lot of other apartment complexes, and seems to best fit your requirements. I hope you have success finding many friends this next semester!
Ben
Note that Stephanie is a fictional character who is based on real experiences of many faculty and staff here at BYU-Idaho.↩︎